package com.guanyong.webapi.controllers.api;

import com.guanyong.model.UserBaseModel;
import com.guanyong.services.VideoBuyLogServices;
import com.guanyong.utils.Comm.ResultCode;
import com.guanyong.utils.Comm.ResultObject;
import com.guanyong.webapi.handle.UserHandle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by mxk on 2017/6/23.
 */
@RestController
@RequestMapping("/api/videobuylog/")
public class VideoBuyLogApi {

    @Autowired
    VideoBuyLogServices videoBuyLogServices;

    @Autowired
    UserHandle userHandle;

    @RequestMapping(value = "checkbuy", method = RequestMethod.POST)
    public ResultObject<Boolean> UpdatePhoto(HttpServletRequest request,
                                             Integer classtype,
                                             String  objectid){
        ResultObject<Boolean> resultObject = new ResultObject<Boolean>();
        UserBaseModel userBaseModel = userHandle.getCurUser(request);
        if (userBaseModel != null && !userBaseModel.getfId().equals("")) {

            Boolean ischeck =
                    videoBuyLogServices.CheckVideoBuy(userBaseModel.getfId(),
                    classtype,
                    objectid);

            resultObject.setResult(ischeck);
        }
        else{
            resultObject.setCode(ResultCode.NoLogin);
        }
        return  resultObject;
    }



}
